package com.usaas.search.controller.admin;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.usaas.common.core.controller.BaseController;
import com.usaas.common.core.domain.AjaxResult;
import com.usaas.common.enums.BusinessType;
import com.usaas.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.usaas.common.annotation.Log;
import com.usaas.search.dto.PlatGameInfoDto;
import com.usaas.search.service.IPlatGameInfoService;
/**
 * 游戏平台Controller
 *
 * @author Helios
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/admin/search/platGameInfo")
public class AdminPlatGameInfoController extends BaseController {

    @Autowired
    private IPlatGameInfoService platGameInfoService;

    /**
     * 查询游戏平台列表
     */
    @PreAuthorize("@ss.hasPermi('search:platGameInfo:list')")
    @Log(title = "管理端游戏平台list查询", businessType = BusinessType.OTHER)
    @PostMapping("/list")
    public AjaxResult list(@RequestBody PlatGameInfoDto platGameInfoDto) {
        List<PlatGameInfoDto> list = platGameInfoService.queryList(platGameInfoDto);
        return AjaxResult.success(list);
    }


    /**
     * 查询游戏平台分页列表
     */
    @PreAuthorize("@ss.hasPermi('search:platGameInfo:list')")
    @Log(title = "管理端游戏平台page查询", businessType = BusinessType.OTHER)
    @PostMapping("/page")
    public AjaxResult page(@RequestBody PlatGameInfoDto platGameInfoDto) {
        return platGameInfoService.queryPage(platGameInfoDto);
    }


    /**
     * 导出游戏平台列表
     */
    @PreAuthorize("@ss.hasPermi('search:platGameInfo:export')")
    @Log(title = "管理端导出游戏平台", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,PlatGameInfoDto platGameInfoDto) {
        List<PlatGameInfoDto> list = platGameInfoService.queryList(platGameInfoDto);
        ExcelUtil<PlatGameInfoDto> util = new ExcelUtil<>(PlatGameInfoDto.class);
        util.exportExcel(response, list, "游戏平台数据");
    }

    /**
     * 获取游戏平台详细信息
     */
    @PreAuthorize("@ss.hasPermi('search:platGameInfo:query')")
    @Log(title = "管理端获取游戏平台详情查询", businessType = BusinessType.OTHER)
    @PostMapping(value = "/getInfo")
    public AjaxResult getInfo(@RequestBody PlatGameInfoDto platGameInfoDto) {
        return AjaxResult.success(platGameInfoService.queryById(platGameInfoDto.getId()));
    }

    /**
     * 新增游戏平台
     */
    @PreAuthorize("@ss.hasPermi('search:platGameInfo:add')")
    @Log(title = "管理端新增游戏平台", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody PlatGameInfoDto platGameInfoDto) {
        return toAjax(platGameInfoService.add(platGameInfoDto));
    }

    /**
     * 修改游戏平台
     */
    @PreAuthorize("@ss.hasPermi('search:platGameInfo:edit')")
    @Log(title = "管理端修改游戏平台", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/edit")
    public AjaxResult edit(@RequestBody PlatGameInfoDto platGameInfoDto) {
        return toAjax(platGameInfoService.update(platGameInfoDto));
    }

    /**
     * 删除游戏平台
     */
    @PreAuthorize("@ss.hasPermi('search:platGameInfo:remove')")
    @Log(title = "管理端删除游戏平台", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public AjaxResult del(@RequestBody PlatGameInfoDto platGameInfoDto) {
        return toAjax(platGameInfoService.removeBatch(platGameInfoDto.getIds()));
    }

}
